package dmir.reaction.publico.graph.neo4j;

import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.index.IndexHits;
import org.neo4j.graphdb.index.IndexManager;
import org.neo4j.graphdb.index.RelationshipIndex;
import org.neo4j.kernel.EmbeddedGraphDatabase;


public class Query {
	
	public static void main(String inputgraph) throws Exception {
		
		GraphDatabaseService graphDb = new EmbeddedGraphDatabase( "politica_teste" ); 
		
		IndexManager index = graphDb.index();
		
		RelationshipIndex cooccurrences = index.forRelationships("cooccurrences");
		
		if (index.existsForRelationships( "cooccurrences" )) {
			
			IndexHits<Relationship> hits = cooccurrences.query( "text", "*corrupção*" );			
			hits.close();
			
			for ( Relationship r :  hits) {
				System.out.print(r.getStartNode().getProperty("ename") + "\t");
				System.out.print(r.getOtherNode(r.getStartNode()).getProperty("ename") + "\t");
				System.out.println(hits.currentScore());
			}			
		}
	}
}
